var ACTION = require("../../base/action");
var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var common = require("./common");
var actionRead = new ACTION("阅读");
actionRead.startRead = function () {
  var content = ["听文章"];
  var ocrItem = ocrGml.findTextOne(
    content,
    true,
    null,
    5,
    (device.height / 10) * 2
  );
  if (ocrItem) {
    utils.clickOcrItem(ocrItem);
    sleep(utils.getRandom(3, 5, 1000));
    var baseSpan = 40;
    var span = utils.getRandom(baseSpan, baseSpan + 5);
    console.log("开始看文章-" + span + "-s");
    common.readArticle(span, 5);
    back();
    sleep(utils.getRandom(2, 4, 1000));
    return;
  }
};

actionRead.exec = function () {
  this.startRead();
};

module.exports = actionRead;
